home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk165 / filesysinfo / fsi.doc < prev    next >
Text File  |  1995-03-19  |  9KB  |  170 lines

  1.  
  2.  
  3.                                     FSI
  4.  
  5.                   A comprehensive File System Information 
  6.                 utility for the Amiga created by Ray Lambert
  7.  
  8.  
  9.     FSI is pure public domain software.  No fee is expected but the author
  10. would like the source code and documentation to remain with the executable
  11. program when passed around.
  12.  
  13.  
  14.  
  15. Overview.
  16.  
  17.     FSI has three purposes in life:  1) To aid beginning AmigaDOS users in
  18. learning and understanding how the Amiga's filing system works; 2) to allow
  19. experienced users to explore the devices in their system, revealing
  20. information for debugging or informational uses; and 3) to aid programmers
  21. in learing and understanding how they can 'smartly' interface their programs
  22. with AmigaDOS.
  23.     The beginning AmigaDOS user can use FSI to identify names of things that
  24. are found in the filing system.  For instance, a beginning user who doesn't
  25. yet understand how ASSIGN works may be confused by logical names such as
  26. "S:", which (usually) refers to a directory called "S" on their Workbench
  27. disk.  They may not understand why they can refer to their boot Workbench
  28. disk as either "DF0:", "Workbench1.3:" or "SYS:".  They may wonder what
  29. those names are that appear under the icons on the Workbench screen.  Any of
  30. these names can be given to FSI.  FSI will identify what they are and what
  31. they refer to, hopefully providing some insight as to how they work
  32. together.
  33.     For more experienced users, FSI will provide information about filing
  34. system devices which may be difficult or impossible to obtain by other
  35. means, including low-level information such as the parameters which are
  36. usually set through 'MountList' entries.
  37.     While no formal documentation is included which explains how or why the
  38. tricks used in this program work, it is hoped that the source code (and
  39. comments therein) will 'speak for itself', thereby fulfilling purpose number
  40. three.  Some initial knowledge of AmigaDOS data structures and operations
  41. will be required to understand the source code.  If you have trouble with
  42. it, "The AmigaDOS Manual 2nd Edition" (published by Bantam Computer Books,
  43. 666 Fifth Avenue, NY, NY, 10103), pages 268 through 277 is a very good place
  44. to start.  You should also read and understand the following Amiga-C header
  45. files:  <libraries/dos.h>, <libraries/dosextens.h> and
  46. <libraries/filehandler.h>.  FSI will certainly not provide a complete
  47. understanding as to how AmigaDOS works, but it will hopefully provide some
  48. insight into the 'dark secrets' in AmigaDOS, and should reveal how to
  49. perform tasks and get information that may be neccessary for some software.
  50. I know I learned a lot by wrting FSI.
  51.  
  52.  
  53.  
  54. Using FSI.
  55.  
  56.     FSI is extremely simple to use and is best learned through actual use.
  57. Try typing "FSI DF0" for an example.
  58.  
  59.     CLI usage: FSI [-x] <device|volume|assign|file|directory name> [...]
  60.                 
  61.     Include -x if you want extended device information.
  62.  
  63.     [...] indicates that multiple parameters are allowed.
  64.  
  65.     FSI does not work from Workbench (sorry :)
  66.  
  67.     
  68.     
  69. Disclaimer.
  70.  
  71.     The following disclaimer is provided mainly for programmers who would
  72. study the source code to FSI.  Those of you who are not programmers have
  73. nothing to fear from what is said below.  Those of you who are programmers
  74. are advised to please read the following as it is a very important aside to
  75. the source code:
  76.  
  77.     FSI works by accessing global AmigaDOS data structures.  While it is
  78. supported to make use of these structures, it is so only if you properly
  79. protect yourself when you do so.  FSI does not!  'Properly protecting
  80. yourself' has nothing to do with condoms or AIDS.  Rather, it means that you
  81. must block other tasks from using these data structures while you are using
  82. them, through the use of the Forbid()/Permit() functions.  If you have
  83. already looked at the source code to FSI, you will have noticed that FSI
  84. _does_ use Forbid() and Permit(), but it does not use them correctly.
  85.  
  86.     First let me explain why FSI is written as such.  FSI started-out as an
  87. experiment -- a vessal to allow me to explore the way in which these file
  88. structures are used.  I wanted to perform tasks such as determining what
  89. volume (if any) is currently mounted in DF0:, or, if a DF1: drive exists in
  90. the system, or, if some volume name (maybe that a user gave me) actually
  91. exists and/or if it is a filing system device or not.  In the end, I learned
  92. how to combine the information in the structures to obtain the information
  93. that I really needed.  FSI is like a poorly planned house which had many
  94. rooms added to it over the course of time with little thought as to their
  95. placement, resulting in an architect's nightmare and an eyesore.  By the
  96. time I was finished with FSI, it had grown into something somewhat large and
  97. complex, something requiring a complete re-write to make it conform to the
  98. rules.  This was out-of-the-question however, because it would simply take
  99. too long to do and I had already gotten out of it what I had needed.  So,
  100. thus it remains: a mere hack.
  101.  
  102.     FSI performs a Forbid() while it is looping through the AmigaDOS device
  103. list, and a Permit() when the loop is over.  However, it then has the nasty
  104. habit of holding pointers that it acquired during the loop and re-using
  105. them.  This is where it violates the rules.  After the Permit() is
  106. performed, multi-tasking is once again enabled, thereby allowing other
  107. programs to access the device list.  Some of these programs may alter the
  108. contents of nodes found in the list, maybe even deleting some.  If a node is
  109. deleted, any pointers to that node held by nasty programs like FSI suddenly
  110. become invalid.  In the worst case, FSI will spew some junk into your CLI
  111. window, or lock-up in an endless loop due to bad pointers -- the guru should
  112. never be summoned because FSI _NEVER_ modifies any of the structures, but
  113. rather only attempts to print the text and numbers it finds in them.
  114.     The proper way to implement a program such as FSI would be to code it in
  115. two stages: 1) scan the lists in a Forbid()den state making COPIES of all the
  116. structures and data that will be needed to create the display; and 2)
  117. generate the display from the copies that where made in stage 1.  Note that
  118. it is absolutely NOT acceptable to simply Forbid() at the beginning of the
  119. program and Permit() at the end.  This is because the act of printing to the
  120. CLI temporarily cancels the effect of your Forbid() call!  'How is this?'
  121. you may ask... well, let me explain... printing to the CLI involves at
  122. least two levels of message passing (the Write() command sends a message to
  123. the device handler and most handlers will then send a message to a .device
  124. to perform the actual I/O) and, when a message is sent to perform
  125. synchronous I/O, a Wait() must be performed.  If a task Forbid()'s and then
  126. Wait()'s, the Wait() cancels the Forbid().  If this didn't happen a deadlock
  127. would result (think about it, Wait() suspends your task, yet you've
  128. forbidden all other tasks from running as well!).  When Wait() returns your
  129. Forbid() is once again in effect, but in the interim another task could have
  130. modified the global data.  A simple example of this is: your task is
  131. printing to the CLI, the user presses the space bar (blocking all output to
  132. the console), opens another CLI (if not already open), and issues an ASSIGN
  133. command to de-assign some logical name.  Bang.  Your pointers are no good!
  134.     Regardless of FSI's disregard for the rules, I felt that the information
  135. provided within may still be exetremely useful to some of you, and so I have
  136. released it as is.  Also, because FSI _NEVER_ writes to any of the data
  137. structures, there is virtually no chance of it causing a guru, so it is
  138. reasonably safe to use.  (This dissertation should be sufficient to convince
  139. you that I don't normally write nasty programs like this and that this is an
  140. exception which I am not at all proud of :] )
  141.  
  142.     The moral of all this is DON'T WRITE PROGRAMS LIKE FSI!  Follow the
  143. rules so that Amiga software will be solid and trustworthy thereby keeping
  144. the Amiga's image strong and prospering!
  145.  
  146.  
  147.  
  148. Acknowledgment.
  149.  
  150.     I would like to acknowledge the help of Douglas R. Merritt through the
  151. source code for his "devinfo" program, especially for showing me how
  152. DLT_DEVICE and DLT_VOLUME nodes are related via the dn_Task field.
  153.  
  154.  
  155.  
  156. Get to know me!
  157.  
  158.     If you have questions, suggestions, flames, propositions, etc., I can be
  159. reached at the following places:
  160.  
  161. PLink:        Analog*Kid    (log on often)
  162.  
  163. BIX:          AnalogKid     (log on sparsely)
  164.  
  165. U.S. Snail:   Ray Lambert
  166.               PO Box 1253
  167.               Westport, Massachusetts  02790
  168.  
  169. Phone:        (508) 677-9217
  170.